package org.example.线程池;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class 自带的线程池 {

    public static void main(String[] args) {
        Executors.newScheduledThreadPool(2); // 定时任务线程池
        Executors.newFixedThreadPool(2); // 固定大小线程池
        Executors.newCachedThreadPool(); // 可缓存线程池
        Executors.newSingleThreadExecutor(); // 单线程线程池
        Executors.newSingleThreadScheduledExecutor(); // 单线程定时任务线程池

        ScheduledExecutorService pool = Executors.newScheduledThreadPool(2);
        pool.schedule(()->{
            System.out.println("ttt");
        }, 1, TimeUnit.SECONDS);
    }
}
